export const getBluetoothDevices = ()=>{
    return new Promise((resolve,reject)=>{
        wx.getBluetoothDevices({
            success({devices}) {
               resolve(devices)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
export const createBLEConnection = ()=>{
    return new Promise((resolve,reject)=>{
        wx.createBLEConnection({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
export const closeBLEConnection = ()=>{
    return new Promise((resolve,reject)=>{
        wx.closeBLEConnection({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
export const openBluetoothAdapter = ()=>{
    return new Promise((resolve,reject)=>{
        wx.openBluetoothAdapter({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
export const closeBluetoothAdapter=()=>{
    return new Promise((resolve,reject)=>{
        wx.closeBluetoothAdapter({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}

export const startBluetoothDevicesDiscovery = ()=>{
    return new Promise((resolve,reject)=>{
        wx.startBluetoothDevicesDiscovery({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
export const stopBluetoothDevicesDiscovery = ()=>{
    return new Promise((resolve,reject)=>{
        wx.stopBluetoothDevicesDiscovery({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}

export const getBluetoothAdapterState = ()=>{
    return new Promise((resolve,reject)=>{
        wx.getBluetoothAdapterState({
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}
